package com.dragon.datastructure.linkedlist;

/**
 * 从尾到头打印单链表
 *
 * @author dragon
 * @since 2019/12/17
 */
public class Test4 {


    private static class Node {
        Node next;
        int val;
    }

    public static void reversePrint(Node head) {
        if (head == null) {
            return;
        }
        reversePrint(head.next);
        System.out.print(head.val + " ");
    }

    public static void main(String[] args) {
        DummyHeadSingleLinkedList<Integer> linkedList = new DummyHeadSingleLinkedList<>();
        linkedList.addLast(1);
        linkedList.addLast(2);
        linkedList.addLast(12);
        linkedList.addLast(211);
        linkedList.reversePrint();
    }
}
